$(function(){
	$(":submit[name='register']").click(function(){
		var phone = $("input[name='phone']").val();
		var password = $("input[name='password']").val();
		var code = $("input[name='code']").val();
		if($.trim(code)==""){
			alert("请输入验证码");
		}else{
            $.ajax({
                url: module_url+"/doregister.do",	                
                type:'post',
    			dataType:"json",
    			data: "phone="+phone+"&password="+password+"&code="+code,
            	success:function(json){
    				if(json.err_code==-1){
    					alert(json.err_msg);
    					window.location.href=module_url+'/login.do';
    				}else{
    					alert(json.err_msg);
    				}
    			},
                error: function () { alert("注册失败") }
            });
		}	
		return false;
	});
	
	$(":submit[name='send']").click(function(){
		var phone = $("input[name='phone']").val();
		if($.trim(phone)==""){
			alert("请输入手机号码");
		}else{
			$.ajax({
	            url: module_url+"/sendphCode.do",	                
	            type:'post',
				dataType:"json",
				data: "phone="+phone,
	        	success:function(json){
					if(json.err_code==-1){
						alert(json.err_msg);
					}else{
						alert(json.err_msg);
					}
				},
	            error: function () { alert("注册失败") }
	        });
		}
	});
});